<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div id="main" style="width: 500px;height: 500px"></div>
	<script src="http://cdn.bootcss.com/socket.io/2.0.3/socket.io.js"></script>
	<script src="http://cdn.bootcss.com/echarts/3.6.2/echarts.js"></script>
	<script>
		// var thedata = [10,10,10,10,10,10]
		
		var thedata=[0,0,0,0,0,0]
        var socket = io('http://localhost:5000')
        
        	socket.on('news', function(data) {
				console.log(data.i)
				thedata.shift()
				thedata.push(data.i)
				myChart.setOption({
			        series: [{
			            name: 'n',
			            data: thedata
			        }]
			    });
				socket.emit('my other event', {my:'ok'})
			})
       
		

		var myChart = echarts.init(document.getElementById('main'));
		var option = {
            title: {
                text: 'ECharts 入门示例'
            },
            tooltip: {},
            legend: {
                data:['n']
            },
            xAxis: {
                data: [1,2,3,4,5,6]
            },
            yAxis: {},
            series: [{
                name: 'n',
                type: 'bar',
                data: [1,2,3,4,5,6] 
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
	</script>
</body>
</html>